<template>
	<view class="content">
		<view class="add">
			<view class="addPictrue" v-for="(item, index) in topicInfo.imgs" :key="index" :src="item" v-if="topicInfo.imgs && topicInfo.imgs.length">
				<image class="img1" :src="item"></image>
				<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/blackClose.png" class="blackClose" @click="$emit('delImg', index)"></image>
				<view v-if="index == 0" class="cover">封面</view>
			</view>
			<view class="addPictrue" v-if="topicInfo.imgs && topicInfo.imgs.length < 6">
				<image class="img1" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/addPicture.png" @click="$emit('addImg')"></image>
			</view>
		</view>
		<!-- 标题 -->
		<view class="title_box"><input type="text" v-model.trim="topicInfo.title" :maxlength="30" placeholder="添加标题~" placeholder-class="placeholder" /></view>
		<!-- 话题 -->
		<view class="chooseTopicBox" v-if="topicInfo.words && topicInfo.words.length">
			<text class="mr10" v-for="(cell, idx) in topicInfo.words" :key="idx">#{{ cell }}#</text>
		</view>
		<!-- 内容 -->
		<u-textarea
			class="textareaBox"
			:adjustPosition="false"
			confirmType="done"
			border="none"
			count
			maxlength="1200"
			v-model="topicInfo.content"
			placeholder="添加正文.."
			placeholderClass="placeholder"
		></u-textarea>
	</view>
</template>

<script>
export default {
	name: '',
	props: {
		topicInfo: Object
	},
	data() {
		return {};
	},
	watch: {
		topicInfo: {
			handler(newVal, oldVal) {
				this.$emit('topicInfoFun', newVal);
				this.$forceUpdate();
			},
			 immediate: true,
			deep: true
		}
	},
	mounted() {}
};
</script>

<style scoped lang="scss">
.content {
	.add {
		padding: 20rpx 40rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;

		.addPictrue {
			position: relative;
			width: 158rpx;
			height: 158rpx;
			margin-right: 15rpx;
			margin-bottom: 15rpx;

			.img1 {
				width: 100%;
				height: 100%;
				border-radius: 20rpx;
			}

			.blackClose {
				width: 32rpx;
				height: 32rpx;
				background: #fff;
				border-radius: 100%;
				position: absolute;
				top: -8rpx;
				right: -6rpx;
				z-index: 9;
			}

			.cover {
				position: absolute;
				left: 0rpx;
				bottom: 0;
				width: fit-content;
				padding: 3rpx 10rpx;
				font-size: 14rpx;
				color: #fff;
				background: rgba(0, 0, 0, 0.6);
				border-radius: 20rpx;
				z-index: 9;
			}
		}

		& > image {
			width: 158rpx;
			height: 158rpx;
		}
	}

	.title_box {
		width: 92%;
		margin: 0 auto;
		padding: 68rpx 0 42rpx 10rpx;
		border-bottom: 2rpx solid rgba(39, 39, 39, 0.1);

		.placeholder {
			font-size: 34rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #b5b5b5;
		}
	}

	.chooseTopicBox {
		font-size: 30rpx;
		font-family: Source Han Sans CN;
		color: #194FC9;
		padding: 46rpx 0 0 40rpx;
	}

	.textareaBox {
		padding: 40rpx;
		line-height: 45rpx;
		min-height: 800rpx;
		::v-deep .uni-textarea-textarea {
			min-height: 800rpx;
		}
	}

	.placeholder {
		font-size: 30rpx;
		color: #b5b5b5;
	}

	.pictureBox {
		padding-left: 30rpx;
		display: flex;
		align-items: center;
		overflow: hidden;
		overflow-x: visible;

		.pictureItem {
			margin-right: 32rpx;

			.img {
				width: 124rpx;
				height: 124rpx;
				border-radius: 20rpx;
			}
		}
	}
}
</style>
